/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ngoctoan
 */
public class Main extends javax.swing.JFrame {

    /**
     * Creates new form Main
     */
    private boolean isLogin = false;

    public Main() {
        initComponents();
        CenterMain();
        Enable();
    }

    private void CenterMain() {
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2 - 20);
    }

    private void Enable() {
        menuItemDanhmuc.setEnabled(isLogin);
        menuItemSanpham.setEnabled(isLogin);
        menuItemNhaphang.setEnabled(isLogin);
        menuItemHoadon.setEnabled(isLogin);
        menuItemDoanhthu.setEnabled(isLogin);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        tbMatkhau = new javax.swing.JPasswordField();
        btnDangnhap = new javax.swing.JButton();
        mainMenu = new javax.swing.JMenuBar();
        menuHethong = new javax.swing.JMenu();
        menuItemThoat = new javax.swing.JMenuItem();
        menuCauhinh = new javax.swing.JMenu();
        menuDanhmuc = new javax.swing.JMenu();
        menuItemDanhmuc = new javax.swing.JMenuItem();
        menuItemSanpham = new javax.swing.JMenuItem();
        menuChucnang = new javax.swing.JMenu();
        menuItemNhaphang = new javax.swing.JMenuItem();
        menuItemXuathang = new javax.swing.JMenuItem();
        menuItemHoadon = new javax.swing.JMenuItem();
        menuThongke = new javax.swing.JMenu();
        menuItemDoanhthu = new javax.swing.JMenuItem();
        menuGiupdo = new javax.swing.JMenu();
        menuItemTacgia = new javax.swing.JMenuItem();
        menuItemSudung = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Hệ thống quản lý bán hàng");
        setResizable(false);

        jPanel1.setPreferredSize(new java.awt.Dimension(938, 20));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel1.setText("Tên đăng nhập");
        jLabel1.setPreferredSize(new java.awt.Dimension(72, 20));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel2.setText("Mật khẩu");
        jLabel2.setPreferredSize(new java.awt.Dimension(72, 20));

        btnDangnhap.setText("Đăng nhập");
        btnDangnhap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDangnhapActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbMatkhau, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnDangnhap)
                .addGap(0, 321, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(tbMatkhau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDangnhap))
                .addContainerGap())
        );

        mainMenu.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N

        menuHethong.setText("Hệ thống");

        menuItemThoat.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
        menuItemThoat.setText("Thoát");
        menuHethong.add(menuItemThoat);

        mainMenu.add(menuHethong);

        menuCauhinh.setText("Cấu hình");
        mainMenu.add(menuCauhinh);

        menuDanhmuc.setText("Quản lý");

        menuItemDanhmuc.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        menuItemDanhmuc.setText("Quản lý danh mục");
        menuItemDanhmuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemDanhmucActionPerformed(evt);
            }
        });
        menuDanhmuc.add(menuItemDanhmuc);

        menuItemSanpham.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK));
        menuItemSanpham.setText("Quản lý sản phẩm");
        menuItemSanpham.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemSanphamActionPerformed(evt);
            }
        });
        menuDanhmuc.add(menuItemSanpham);

        mainMenu.add(menuDanhmuc);

        menuChucnang.setText("Chức năng");

        menuItemNhaphang.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
        menuItemNhaphang.setText("Nhập hàng hóa");
        menuItemNhaphang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemNhaphangActionPerformed(evt);
            }
        });
        menuChucnang.add(menuItemNhaphang);

        menuItemXuathang.setText("Xuất hàng hóa");
        menuChucnang.add(menuItemXuathang);

        menuItemHoadon.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK));
        menuItemHoadon.setText("Lập hóa đơn bán hàng");
        menuItemHoadon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemHoadonActionPerformed(evt);
            }
        });
        menuChucnang.add(menuItemHoadon);

        mainMenu.add(menuChucnang);

        menuThongke.setText("Thống kê - Báo cáo");

        menuItemDoanhthu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.ALT_MASK));
        menuItemDoanhthu.setText("Doanh thu");
        menuItemDoanhthu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemDoanhthuActionPerformed(evt);
            }
        });
        menuThongke.add(menuItemDoanhthu);

        mainMenu.add(menuThongke);

        menuGiupdo.setText("Giúp đở");

        menuItemTacgia.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK));
        menuItemTacgia.setText("Thông tin tác giả");
        menuGiupdo.add(menuItemTacgia);

        menuItemSudung.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.ALT_MASK));
        menuItemSudung.setText("Hướng dẫn sử dụng");
        menuGiupdo.add(menuItemSudung);

        mainMenu.add(menuGiupdo);

        setJMenuBar(mainMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(desktopPane)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 884, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 16, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuItemDanhmucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemDanhmucActionPerformed
        // TODO add your handling code here:
        DanhmucGUI dmGUI = null;
        dmGUI = new DanhmucGUI();
        desktopPane.add(dmGUI);
        dmGUI.setVisible(true);
    }//GEN-LAST:event_menuItemDanhmucActionPerformed

    private void menuItemSanphamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemSanphamActionPerformed
        // TODO add your handling code here:
        SanphamGUI spGUI = null;

        spGUI = new SanphamGUI();
        desktopPane.add(spGUI);
        spGUI.setVisible(true);
    }//GEN-LAST:event_menuItemSanphamActionPerformed

    private void menuItemNhaphangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemNhaphangActionPerformed

        NhaphangGUI nhGUI = null;
        nhGUI = new NhaphangGUI();
        desktopPane.add(nhGUI);
        nhGUI.setVisible(true);
    }//GEN-LAST:event_menuItemNhaphangActionPerformed

    private void menuItemHoadonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemHoadonActionPerformed
        // TODO add your handling code here:
        HoadonGUI hdGUI = null;
        try {
            hdGUI = new HoadonGUI();
        } catch (PropertyVetoException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        desktopPane.add(hdGUI);
        hdGUI.setVisible(true);
    }//GEN-LAST:event_menuItemHoadonActionPerformed

    private void menuItemDoanhthuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemDoanhthuActionPerformed
        // TODO add your handling code here:
        DoanhthuGUI dtGUI = null;
        dtGUI = new DoanhthuGUI();
        desktopPane.add(dtGUI);
        dtGUI.setVisible(true);
    }//GEN-LAST:event_menuItemDoanhthuActionPerformed

    private void btnDangnhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDangnhapActionPerformed
        // TODO add your handling code here:
        isLogin = true;
        Enable();
    }//GEN-LAST:event_btnDangnhapActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Main().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDangnhap;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JMenuBar mainMenu;
    private javax.swing.JMenu menuCauhinh;
    private javax.swing.JMenu menuChucnang;
    private javax.swing.JMenu menuDanhmuc;
    private javax.swing.JMenu menuGiupdo;
    private javax.swing.JMenu menuHethong;
    private javax.swing.JMenuItem menuItemDanhmuc;
    private javax.swing.JMenuItem menuItemDoanhthu;
    private javax.swing.JMenuItem menuItemHoadon;
    private javax.swing.JMenuItem menuItemNhaphang;
    private javax.swing.JMenuItem menuItemSanpham;
    private javax.swing.JMenuItem menuItemSudung;
    private javax.swing.JMenuItem menuItemTacgia;
    private javax.swing.JMenuItem menuItemThoat;
    private javax.swing.JMenuItem menuItemXuathang;
    private javax.swing.JMenu menuThongke;
    private javax.swing.JPasswordField tbMatkhau;
    // End of variables declaration//GEN-END:variables
}
